package com.myProject.order.controller;

import com.myProject.order.entity.ProductCategory;
import com.myProject.order.service.ProductCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Created by xhw on 2017/08/06.
 */

@RestController
@RequestMapping("/api/product")
public class ProductCategoryController {

    @Autowired
    private ProductCategoryService productCategoryService;

    @PostMapping(value = "/save")
    public String saveProduct(){
        ProductCategory productCategory = new ProductCategory();
        productCategory.setCategoryName("五花肉");
        productCategory.setCategoryType(1);
        productCategoryService.saveProduct(productCategory);
        return productCategory.toString();
    }

    @GetMapping(value = "/get")
    public List<ProductCategory> getProduct(){
        return productCategoryService.findList();
//        return productCategory.toString();
    }
}
